package com.lcz.manage.util.event.publisher.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 发送器类型
 *
 * @author xingyongjiang@yunrong.cn
 * @version V3.0
 * @since 2021/4/19 13:10
 */
@Getter
@AllArgsConstructor
public enum PublisherType {
    /** 描述 */
    SYNC("010", "同步发送器"),
    THREAD_POLL_ASYNC("020", "线程池异步发送器"),
    MQ_ASYNC("020", "mq异步发送器"),
    ;

    /** 状态码 */
    private String code;

    /** 状态描述 */
    private String description;

    /**
     * 根据编码查找枚举
     *
     * @param code 编码
     * @return {@link PublisherType } 实例
     **/
    public static PublisherType find(String code) {
        for (PublisherType instance : PublisherType.values()) {
            if (instance.getCode()
                .equals(code)) {
                return instance;
            }
        }
        return null;
    }
}
